package com.yantong.service;

import com.yantong.pojo.*;
import com.yantong.pojo.vo.CommanerVo;
import com.yantong.pojo.vo.LocalLifeStoreVo;
import com.yantong.result.ResultVo;
import com.yantong.utils.PageUtils;
import org.apache.ibatis.annotations.Param;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author xiangyi
 * @version V1.0.0
 * @Description:
 * Copyright: Copyright (c) 2018
 * Company: 会员管理 Service
 * @date 2018年8月28日 下午6:34:14
 * @since 3.0
 */
public interface MemberService {


	/**
	 * 会员基础信息
	 *
	 * @param id
	 * @return
	 */
	Member getByKey(Long id);




	List<Member> listCenterTeamList(Long centerId);


	List<Member> listCenterList(Long centerId);

	List<Member> getAllMember(Map params);


	Member login(String mobile, String encPassword, Long centerId);



	/**
	 * 通过会员编号查询到绑定门店信息
	 *
	 * @param memberId
	 * @return
	 */
	CommanerVo getCommanderByMembId(Long memberId);

	/**
	 * 门店基础信息
	 *
	 * @param tmid
	 * @return
	 */
	Member getTmByKey(Long tmid);


	/**
	 * 取消会员并整改下级的上级门店
	 *
	 * @param member
	 * @return
	 */
	int cancelCommanderUpdate(Member member);

	/**
	 * 寻找下级门店
	 *
	 * @param upTeamid
	 * @return
	 */
	List<Member> getSubordinate(Long upTeamid);

	/**
	 * 会员详情
	 *
	 * @param mid
	 * @return
	 */
	Member getDetail(Long mid);

	/**
	 * 更新会员
	 *
	 * @param member
	 * @return
	 */
	int updateMember(Member member);

	ResultVo noCheckUpdate(Member member);

	/**
	 * 异步更新会员信息
	 *
	 * @param member
	 * @return
	 */
	void updateMemberAsync(Member member);

	/**
	 * 关键词查询会员列表分页数据
	 *
	 * @param queryItem
	 * @param centreId
	 * @param offset
	 * @param limit
	 * @return
	 */
	PageUtils<Member> queryList(String queryItem, Long centreId, int offset, int limit, Integer isteam);


	/**
	 * 获取会员列表数据
	 *
	 * @param listMemberParams
	 * @param member
	 * @param offset
	 * @param limit
	 * @return
	 */
	PageUtils<Member> listMembers(ListMemberParams listMemberParams, Member member, int offset, int limit);


	/**
	 * 得到门店下面的用户
	 *
	 * @param params
	 * @param rowBounds
	 * @return
	 */
	PageUtils<Member> getTeamtheUserByMid(Long mid, int offset, int limit);


	/**
	 * 得到门店下面的用户
	 *
	 * @param params
	 * @param rowBounds
	 * @return
	 */
	List<Member> getTeamtheUserByMid(Long mid);



	/**
	 * 更新t_member并插保证金记录
	 *
	 * @param member
	 * @param bondFlow
	 * @param flag
	 * @return
	 */
	int updateMemberAndBondFlow(Member member, BondFlow bondFlow, int flag);


	/**
	 * 查询推荐门店
	 *
	 * @param queryItem
	 * @param centreId
	 * @param offset
	 * @param limit
	 * @return
	 */
	PageUtils<Member> queryComList(String queryItem, Long centreId, int offset, int limit);



	/**
	 * 更新资产并插资产记录
	 *
	 * @param member
	 * @return
	 */
	int changeMemberAndWallet(Member member, MemberWalletLog memberWalletLog);

	/**
	 * 获取会员列表数据
	 *
	 * @param listMemberParams
	 * @param member
	 * @param offset
	 * @param limit
	 * @return
	 */
	List<Member> epListMembers(ListMemberParams listMemberParams, Member member);


	int updatePassword(UpdatePasswordReq updatePasswordReq);


	/**
	 *  更新用户会员状态和佣金分发
	 *
	 * @param [mid]
	 * @return int
	 * @author huangshuai
	 * @date 2021/1/18 16:42
	 */
	int updateMeberVipAndCommission(Long mid);

	/**
	 * 判断会员是否可以分佣
	 *
	 * @param member 用户信息
	 * @return boolean
	 * @author liaozhaogui
	 * @date 2021/1/26 14:12
	 */
	boolean commissionFlag(Member member,Integer type);


	/**
	 * 获取门店列表
	 *
	 * @param tmid
	 * @param queryItem
	 * @param offset
	 * @param limit
	 * @return
	 */
	PageUtils<Member> listAllShops(Map<String,Object> param);

	/**
	 * 门店注册
	 *
	 * @param member
	 * @return
	 */
	int registTeam(Member member);


	/**
	 * 获取当前位置下3公里以内的门店列表
	 * 当查询名称为空时，按坐标查询，名称有值时按名称查询
	 *
	 * @param longitude
	 * @param latitude
	 * @param teamName
	 * @param offset
	 * @param limit
	 * @param flag      1平台和平台商户 2商户
	 * @return
	 */
	List<Member> getNewNearCommanders(Double longitude, Double latitude, String teamName,
									  Long centreId, Long mid, Integer flag,Integer terminalIds, int offset, int limit,
									  Integer isLocalLifeStoreFlag, Integer isAppletsStoreFlag,Long industryBrandId) throws ParseException;

	/**
	 * 新增会员访问记录
	 *
	 * @param log
	 * @return
	 */
	int saveAccessLog(AccessLog log);


	/**
	 * 获取当前位置下3公里以内的门店列表
	 * 当查询名称为空时，按坐标查询，名称有值时按名称查询
	 *
	 * @param longitude
	 * @param latitude
	 * @param teamName
	 * @param offset
	 * @param limit
	 * @param flag      1平台和平台商户 2商户
	 * @return
	 */
	List<Member> getNearCommanders(double longitude, double latitude, String teamName,
								   Long centreId, Long mid, Integer flag, int offset, int limit);

	/**
	 * 获取门店排行信息
	 *
	 * @param tmid     当前门店ID
	 * @param timeType 对应常量 TimeType
	 * @return
	 */
	Map<String, Object> getShopRankings(Long tmid, Integer timeType);

	/**
	 * 获取门店下会员列表
	 *
	 * @param tmid
	 * @param queryItem
	 * @param offset
	 * @param limit
	 * @return
	 */
	PageUtils<Member> listTeamMembers(Long tmid, String queryItem, int offset, int limit);


	/**
	 * 通过小程序openId获取会员信息，
	 * 使用场景1，微信端获取会员信息
	 *
	 * @param openId
	 * @return
	 */
	Member getByAppOpenId(String openId);

	/**
	 * 微信购买vip
	 *
	 * @param mid
	 * @param payNo
	 * @param invCode
	 * @return
	 */
	int buyVipWx(Long mid, String payNo, String invCode);


	Member getTmByTeamSeqId(String teamSeqId);

	LocalLifeStoreVo getLocalStoreDetail(Long shopId);

	/**
	 * 获取用户发码权限信息
	 *
	 * @return
	 */
	Member getMemberCdkSendLimit(Long mid);


	/**
	 * 获取门店时间段内的群订单数和订单金额数据
	 *
	 * @param teamId
	 * @param start
	 * @param end
	 * @return
	 */
	List<Map<String, Object>> getCommanderProfitInfo(Long teamId, Date start, Date end);


	/**
	 * 门店今日预期收益
	 *
	 * @param teamId
	 * @return
	 */
	double getTodayExpectIncome(Long teamId);

	/**
	 * 获取门店合作门店列表
	 *
	 * @param tmid
	 * @param queryItem
	 * @param offset
	 * @param limit
	 * @return
	 */
	PageUtils<Member> listTeamCommanders(Long tmid, String queryItem, int offset, int limit);

	int buyVipByBalanceCard(Long mid, String invCode, String level);

	/**
	 * 通过openId获取会员信息，
	 * 使用场景1，微信端获取会员信息
	 *
	 * @param openId
	 * @return
	 */
	Member getByOpenId(String openId);

	Member getByUnionId(String unionId);

	/**
	 * 新增会员信息,
	 * 使用场景1，会员授权自动注册
	 *
	 * @param member
	 * @return 会员记录主键ID
	 */
	long saveMember(Member member);

	int updateByPrimaryKeySelective(Member record);

	/**
	 * 设置用户前端ticket
	 *
	 * @param mid
	 * @param ticket
	 * @return ticket值
	 */
	String setTicket(Long mid, String ticket);

	List<Member> getMemByUserId(Map params);

	int buyVipWxCard(Long mid, String payNo, String invCode, String level);

	/**
	 * 微信购买vip
	 *
	 * @param mid
	 * @param payNo
	 * @param invCode
	 * @param vipType
	 * @return
	 */
	int buyLifeVipWx(Long mid, String payNo, String invCode,Integer vipType);

	/**
	 * 根据centerId获得平台的 ShopMemberId (门店id)
	 * @param centerId
	 * @return
	 */
	Long getCenterIdByShopMemberId(Long centerId);

	/**
	 * 根据shopMemberId 获得 centerId
	 * @param shopMemberId
	 * @return
	 */
	Long getShopMemberIdByCenterId(Long shopMemberId);

	Member getOneByCentreIdAndMobile(Long centreId, String loginMobile);
}
